import 'package:flutter/material.dart';
import 'package:flutter_baidu_mapapi_map/flutter_baidu_mapapi_map.dart';
import 'package:im_module/map/BMFBaseMapState.dart';
import 'package:im_module/widget/AppBarBackground.dart';

class BDMapPage extends StatefulWidget {
  double? longitude;
  double? latitude;

  BDMapPage(this.latitude, this.longitude);

  @override
  _BDMapPageState createState() => _BDMapPageState();
}

class _BDMapPageState extends BMFBaseMapState<BDMapPage> {
  @override
  void initState() {
    super.initState();

    setState(() {
      moveCurrent = false;
    });
  }

  @override
  void onBMFMapCreated(BMFMapController controller) {
    super.onBMFMapCreated(controller);
  }

  void loadMapSuccess() {
    super.loadMapSuccess();
    if (widget.latitude != 0) {
      moveMap(widget.latitude, widget.longitude, true);
    }
  }

  @override
  Widget build(BuildContext context) {
    return AppBarBackground(
      child: Scaffold(
        appBar: AppBar(
          title: Text("查看地址"),
        ),
        body: Container(
          color: Colors.white,
          child: Stack(
            children: [
              generateMap(),
              Center(
                child: Icon(Icons.location_on, color: Colors.blue, size: 32),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
